package groovy
import com.alibaba.fastjson.JSON
import com.aliyun.dingtalkworkflow_1_0.Client
import com.aliyun.dingtalkworkflow_1_0.models.CancelIntegratedTaskHeaders
import com.aliyun.dingtalkworkflow_1_0.models.CancelIntegratedTaskRequest
import com.aliyun.teaopenapi.models.Config
import com.aliyun.teautil.models.RuntimeOptions;
static Client createClient()  {
    Config config = new Config();
    config.protocol = "https";
    config.regionId = "central";
    return new Client(config);
}
static String cancelTask(String token,String processInstanceId,List<String> activityIds) {
    Client client = createClient();
    CancelIntegratedTaskHeaders cancelIntegratedTaskHeaders = new CancelIntegratedTaskHeaders();
    cancelIntegratedTaskHeaders.xAcsDingtalkAccessToken = token;
    CancelIntegratedTaskRequest cancelIntegratedTaskRequest = new CancelIntegratedTaskRequest()
            .setProcessInstanceId(processInstanceId)
            .setActivityId(activityIds[0])
    .setActivityIds(activityIds)
    JSON.toJSONString(client.cancelIntegratedTaskWithOptions(cancelIntegratedTaskRequest, cancelIntegratedTaskHeaders, new RuntimeOptions()).body)
}
